package com.mhkj.revise.plan.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.mhkj.base.functionOffice.entity.FunctionOffice;
import com.mhkj.base.itemInfo.item.entity.Item;
import com.mhkj.base.templete.entity.PlanTemplete;
import com.mics.core.common.validate.annotation.NotNull;
import com.mics.core.common.validate.annotation.Unique;
import com.mics.core.common.validate.annotation.Validate;
import com.mics.core.system.base.entity.BaseDomain;
import com.mics.core.system.rbac.entity.Dictionary;

/**
 * 项目计划
 * @author mics
 * @date 2018年7月5日
 * @version 1.0
 */
@Entity
@Table(name="t_plan")
@Validate
public class Plan extends BaseDomain{

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 770788413423354155L;
	
	/**
	 * 前置计划
	 */
	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="plan_id")
	private Plan plan;
	
	/**
	 * 计划名称
	 */
	@NotNull(message="计划名称不能为空")
	@Column(name="name")
	@Unique(message="计划名称不能重复")
	private String name;
	
	/**
	 * 项目名称
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="item_id")
	private Item item;
	
	
	/**
	 * 职能部门
	 */
	@JoinColumn(name="function_office")
	@ManyToOne(fetch=FetchType.LAZY)
	private FunctionOffice functionOffice;
	
	/**
	 * 计划类别  1、关键计划  2、主项计划  3、专项计划  4、职能计划  5、月度计划
	 */
	@JoinColumn(name="plan_type_id")
	@ManyToOne(fetch=FetchType.LAZY)
	private Dictionary planType;
	
	/**
	 * 模板
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="plan_templete_id")
	private PlanTemplete planTemplete;
	
	/**
	 * 计划开始时间
	 */
	@Column(name="begin_date")
	@Temporal(TemporalType.DATE)
	private Date beginDate;
	
	/**
	 * 计划结束时间
	 */
	@Column(name="end_date")
	@Temporal(TemporalType.DATE)
	private Date endDate;
	
	/**
	 * 状态 0、未提交 1、审核中   2、审核通过   3、审核失败
	 */
	@Column(name="state")
	private int state=0;

	/**
	 * 审批时间
	 */
	@Column(name="audit_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date auditDate;
	/**
	 * 审批说明
	 */
	@Column(name="audit_remark",length=120)
	private String auditRemark;

	/**
	 * 计划节点列表
	 */
	@OneToMany(mappedBy="plan")
	@LazyCollection(LazyCollectionOption.EXTRA)
	private List<PlanNode> planNodes;
	
	
	public Date getAuditDate() {
		return auditDate;
	}

	public void setAuditDate(Date auditDate) {
		this.auditDate = auditDate;
	}

	public String getAuditRemark() {
		return auditRemark;
	}

	public void setAuditRemark(String auditRemark) {
		this.auditRemark = auditRemark;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	
	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}


	public PlanTemplete getPlanTemplete() {
		return planTemplete;
	}

	public void setPlanTemplete(PlanTemplete planTemplete) {
		this.planTemplete = planTemplete;
	}

	public Dictionary getPlanType() {
		return planType;
	}

	public void setPlanType(Dictionary planType) {
		this.planType = planType;
	}

	public Plan getPlan() {
		return plan;
	}

	public void setPlan(Plan plan) {
		this.plan = plan;
	}

	public List<PlanNode> getPlanNodes() {
		return planNodes;
	}

	public void setPlanNodes(List<PlanNode> planNodes) {
		this.planNodes = planNodes;
	}

	public FunctionOffice getFunctionOffice() {
		return functionOffice;
	}

	public void setFunctionOffice(FunctionOffice functionOffice) {
		this.functionOffice = functionOffice;
	}


	
	
}
